package com.openbravo.pos.ticket;

import com.openbravo.basic.BasicException;
import com.openbravo.data.gui.ComboBoxValModel;
import com.openbravo.data.gui.ListQBFModelNumber;
import com.openbravo.data.loader.QBFCompareEnum;
import com.openbravo.data.loader.SentenceList;
import com.openbravo.data.user.EditorCreator;
import com.openbravo.editor.JEditorCurrency;
import com.openbravo.editor.JEditorKeys;
import com.openbravo.editor.JEditorString;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.DataLogicSales;
import java.awt.Dimension;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ProductFilterSales extends JPanel
  implements EditorCreator
{
  private SentenceList m_sentcat;
  private ComboBoxValModel m_CategoryModel;
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JLabel jLabel4;
  private JLabel jLabel5;
  private JComboBox m_jCategory;
  private JComboBox m_jCboPriceBuy;
  private JComboBox m_jCboPriceSell;
  private JEditorCurrency m_jPriceBuy;
  private JEditorCurrency m_jPriceSell;
  private JEditorString m_jtxtBarCode;
  private JEditorString m_jtxtName;

  public ProductFilterSales(DataLogicSales paramDataLogicSales, JEditorKeys paramJEditorKeys)
  {
    initComponents();
    this.m_sentcat = paramDataLogicSales.getCategoriesList();
    this.m_CategoryModel = new ComboBoxValModel();
    this.m_jCboPriceBuy.setModel(ListQBFModelNumber.getMandatoryNumber());
    this.m_jPriceBuy.addEditorKeys(paramJEditorKeys);
    this.m_jCboPriceSell.setModel(ListQBFModelNumber.getMandatoryNumber());
    this.m_jPriceSell.addEditorKeys(paramJEditorKeys);
    this.m_jtxtName.addEditorKeys(paramJEditorKeys);
    this.m_jtxtBarCode.addEditorKeys(paramJEditorKeys);
  }

  public void activate()
  {
    this.m_jtxtBarCode.reset();
    this.m_jtxtBarCode.setEditModeEnum(3);
    this.m_jtxtName.reset();
    this.m_jPriceBuy.reset();
    this.m_jPriceSell.reset();
    this.m_jtxtName.activate();
    try
    {
      List localList = this.m_sentcat.list();
      localList.add(0, null);
      this.m_CategoryModel = new ComboBoxValModel(localList);
      this.m_jCategory.setModel(this.m_CategoryModel);
    }
    catch (BasicException localBasicException)
    {
    }
  }

  public Object createValue()
    throws BasicException
  {
    Object[] arrayOfObject = new Object[10];
    if ((this.m_jtxtName.getText() == null) || (this.m_jtxtName.getText().equals("")))
    {
      arrayOfObject[0] = QBFCompareEnum.COMP_NONE;
      arrayOfObject[1] = null;
    }
    else
    {
      arrayOfObject[0] = QBFCompareEnum.COMP_RE;
      arrayOfObject[1] = ("%" + this.m_jtxtName.getText() + "%");
    }
    arrayOfObject[3] = this.m_jPriceBuy.getDoubleValue();
    arrayOfObject[2] = (arrayOfObject[3] == null ? QBFCompareEnum.COMP_NONE : this.m_jCboPriceBuy.getSelectedItem());
    arrayOfObject[5] = this.m_jPriceSell.getDoubleValue();
    arrayOfObject[4] = (arrayOfObject[5] == null ? QBFCompareEnum.COMP_NONE : this.m_jCboPriceSell.getSelectedItem());
    if (this.m_CategoryModel.getSelectedKey() == null)
    {
      arrayOfObject[6] = QBFCompareEnum.COMP_NONE;
      arrayOfObject[7] = null;
    }
    else
    {
      arrayOfObject[6] = QBFCompareEnum.COMP_EQUALS;
      arrayOfObject[7] = this.m_CategoryModel.getSelectedKey();
    }
    if ((this.m_jtxtBarCode.getText() == null) || (this.m_jtxtBarCode.getText().equals("")))
    {
      arrayOfObject[8] = QBFCompareEnum.COMP_NONE;
      arrayOfObject[9] = null;
    }
    else
    {
      arrayOfObject[8] = QBFCompareEnum.COMP_RE;
      arrayOfObject[9] = ("%" + this.m_jtxtBarCode.getText() + "%");
    }
    return arrayOfObject;
  }

  private void initComponents()
  {
    this.jLabel5 = new JLabel();
    this.m_jtxtName = new JEditorString();
    this.jLabel2 = new JLabel();
    this.m_jCategory = new JComboBox();
    this.jLabel4 = new JLabel();
    this.m_jCboPriceBuy = new JComboBox();
    this.m_jPriceBuy = new JEditorCurrency();
    this.jLabel3 = new JLabel();
    this.m_jCboPriceSell = new JComboBox();
    this.m_jPriceSell = new JEditorCurrency();
    this.m_jtxtBarCode = new JEditorString();
    this.jLabel1 = new JLabel();
    setPreferredSize(new Dimension(370, 170));
    setLayout(null);
    this.jLabel5.setText(AppLocal.getIntString("label.prodname"));
    add(this.jLabel5);
    this.jLabel5.setBounds(20, 40, 110, 15);
    add(this.m_jtxtName);
    this.m_jtxtName.setBounds(130, 40, 290, 25);
    this.jLabel2.setText(AppLocal.getIntString("label.prodcategory"));
    add(this.jLabel2);
    this.jLabel2.setBounds(20, 70, 110, 15);
    add(this.m_jCategory);
    this.m_jCategory.setBounds(130, 70, 260, 24);
    this.jLabel4.setText(AppLocal.getIntString("label.prodpricebuy"));
    add(this.jLabel4);
    this.jLabel4.setBounds(20, 100, 110, 15);
    add(this.m_jCboPriceBuy);
    this.m_jCboPriceBuy.setBounds(130, 100, 150, 24);
    add(this.m_jPriceBuy);
    this.m_jPriceBuy.setBounds(290, 100, 130, 25);
    this.jLabel3.setText(AppLocal.getIntString("label.prodpricesell"));
    add(this.jLabel3);
    this.jLabel3.setBounds(20, 130, 110, 15);
    add(this.m_jCboPriceSell);
    this.m_jCboPriceSell.setBounds(130, 130, 150, 24);
    add(this.m_jPriceSell);
    this.m_jPriceSell.setBounds(290, 130, 130, 25);
    add(this.m_jtxtBarCode);
    this.m_jtxtBarCode.setBounds(130, 10, 290, 25);
    this.jLabel1.setText(AppLocal.getIntString("label.prodbarcode"));
    add(this.jLabel1);
    this.jLabel1.setBounds(20, 10, 110, 15);
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.ticket.ProductFilterSales
 * JD-Core Version:    0.6.0
 */